<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 11、国际BMI

扩展：

输入年，月，日，求出该日期是当前年的第几天

个人所得税的计算器 -->
    请输入:
    <input id="year" type="text" />年
    <input id="month" type="text" />月
    <input id="date" type="text" />日
    <input type="button" value="第几天" onclick="testf()">
    <input id="result" type="text">天
    <!-- <script>
        function testf() {
            var year = Number(document.getElementById("year").value);
            var month = Number(document.getElementById("month").value);
            var date = Number(document.getElementById("date").value);

            var total = 0;
            switch (month) {
                case 12: total += 30;
                case 11: total += 31;
                case 10: total += 30;
                case 9: total += 31;
                case 8: total += 31;
                case 7: total += 30;
                case 6: total += 31;
                case 5: total += 30;
                case 4: total += 31;
                case 3:
                    if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
                        total += 29
                    }
                    else {
                        total += 28
                    }
                case 2: total += 31;
                case 1: total += date; break;
            }

            
            document.getElementById("result").value = total;

        }

    </script> -->
    <script>
      function isRunYear(year) {
    // if((year%4==0 && year%100!=0)||(year%400==0)){                
    //     return true;
    // }
    // return false;     
    return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)
}
        function dayCount(year, month, date) {
            var dayCount = 0;
            switch (month) {
                case 12: dayCount += 30;
                case 11: dayCount += 31
                case 10: dayCount += 30
                case 9: dayCount += 31
                case 8: dayCount += 31
                case 7: dayCount += 30
                case 6: dayCount += 31
                case 5: dayCount += 30
                case 4: dayCount += 31
                case 3: dayCount += isRunYear(year) ? 29 : 28;;
                case 2: dayCount += 31;
                case 1: dayCount += date; break;
            }
            return dayCount;
        }
        function testf() {
            var year1 = document.getElementById("year").value/1;
            var month1 = document.getElementById("month").value/1;
            var day1 = document.getElementById("date").value/1;
       
        var s =  dayCount(year1, month1, day1);
        document.getElementById("result").value = s
            }
    </script>
</body>

</html>